https://leetcode.cn/problems/maximum-subarray/submissions/672259900/

class Solution {
public:
	int maxSubArray(vector<int>& nums) {
		int sum=nums[0],ans=nums[0];
		int len=nums.size();
		for(int i=1;i<len;i++){
			if(sum>0){
				sum+=nums[i];
			}
			else sum=nums[i];
			ans=max(sum,ans);
		}
		return ans;
	}
};
